soda() 
	._page('demo_user') 
	._api('/v1/demo/user') 
	._query([]) 
	._orderBy(['createTime^desc']) 
	._run((unit) => { 
		// 表单配置 
		unit.templateForm['verify'] = []; 
		unit.templateForm['items'] = [ 
			    {code: 1, name: 'realName', title: '真实姓名', placeholder: '请填写真实姓名'}, 
                {code: 1, name: 'mobile', title: '手机号码 唯一判断', placeholder: '请填写手机号码 唯一判断'}, 
                {code: 1, name: 'gender', title: '性别 男 女', placeholder: '请填写性别 男 女'}, 
                {code: 1, name: 'email', title: '电子邮箱', placeholder: '请填写电子邮箱'}, 
                {code: 1, name: 'avatar', title: '头像', placeholder: '请填写头像'}, 
                {code: 1, name: 'remark', title: '备注', placeholder: '请填写备注'}, 
 
		]; 
 
		// 表格基础配置 
		unit.templateTable['cols'] = [ 
			    {field: 'realName', title: '真实姓名', minWidth: 120}, 
                {field: 'mobile', title: '手机号码 唯一判断', minWidth: 120}, 
                {field: 'gender', title: '性别 男 女', minWidth: 120}, 
                {field: 'email', title: '电子邮箱', minWidth: 120}, 
                {field: 'avatar', title: '头像', minWidth: 120}, 
                {field: 'remark', title: '备注', minWidth: 120}, 

			{field: 'createTime', title: '创建时间'}, 
			{field: 'updateTime', title: '上次修改', templet(obj) { 
				let ct = obj.createTime; 
				let ut = obj.updateTime; 
				return ct == ut ? '' : ut; 
			}}, 
			{fixed: 'right', title: '操作', minWidth: 120, toolbar: unit.sysApplication['btns']['right']()} 
		]; 
		unit.templateTable['bar'] = (opt) => { 
			unit.templateDialog[opt.event](); 
		} 
unit.templateTable['tool'] = (opt) => { 
			unit.templateDialog[opt.event](opt.data); 
		} 
		// 表格查询配置 
		unit.templateTable['search']['components'] = [ 
			{code:1, name:"key", title:"关键字", placeholder:"请输入要查询的关键字"} 
		] 
		unit.templateTable['search']['submit'] = (data) => { 
			unit.sdTable.reload(unit.el['table'], { 
				where: unit.sdFormat['query'](unit.filter['vo'], data) 
			}); 
		} 
 
		//弹出层 
		unit.templateDialog['form'] = (data) => { 
			unit.sdDialog.form({ 
				title: data ? '修改' : "创建", 
				height: '500px', 
				init() { 
					unit.sdForm['init']['form'](unit.templateForm, data); 
				}, 
				opt(index) { 
					// 获取form 
					let form = unit.sdForm['get'](unit.el['form'], unit.templateForm['verify']); 
					// 校验数据
					if (!form.check) {
						unit.sdDialog['tips']['warning'](form.message);
						return false;
					}
					// 数据处理
					let val = form.data;
 
					let param = {
						url: unit.api['crud'],
						data: val,
						tips: true,
						callback: function() {
							unit.sdDialog['close'](index);
							unit.sdTable['reload'](unit.el.table);
						}
					}
					// 操作
					data ? unit.sdHttp['put'](param, data.id) : unit.sdHttp['post'](param);
				} 
			}) 
		} 
		unit.templateDialog['create'] = unit.templateDialog['form'];
		unit.templateDialog['update'] = unit.templateDialog['form'];
		unit.templateDialog['delete'] = (data) => {
			unit.sdDialog.confirm({
				title: "是否要删除这条数据?",
				submit() {
					let param = {
 						url: unit.api['crud'],
 						callback() {
 							unit.sdTable['reload'](unit.el.table)
 						}
 					}
 					unit.sdHttp['delete'](param, data.id);
 				}
 			});
 		}
 		unit.sdTable['render'](unit.templateTable);
 	}); 